package com.cddx.logistics.service.impl;

import com.cddx.logistics.domain.dto.InsuranceQueryDTO;
import com.cddx.logistics.domain.pojo.Insurance;
import com.cddx.logistics.domain.vo.InsuranceVO;
import com.cddx.logistics.mapper.InsuranceMapper;
import com.cddx.logistics.service.InsuranceService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class InsuranceServiceImpl implements InsuranceService {
    @Resource
    private InsuranceMapper insuranceMapper;

    @Override
    public PageInfo<InsuranceVO> queryPage(InsuranceQueryDTO queryDTO) {
        PageHelper.startPage(queryDTO.getPage(), queryDTO.getLimit());
        List<InsuranceVO> list = insuranceMapper.queryPage(queryDTO);
        return new PageInfo<>(list);
    }

    @Override
    public boolean add(Insurance insurance) {
        return insuranceMapper.add(insurance) > 0;
    }

    @Override
    public boolean update(Insurance insurance) {
        return insuranceMapper.update(insurance) > 0;
    }

    @Override
    public boolean delete(Integer id) {
        return insuranceMapper.delete(id) > 0;
    }

    @Override
    public boolean batchDelete(List<Integer> ids) {
        return insuranceMapper.batchDelete(ids) > 0;
    }
}